<?php 
require('class.image-resize.php');

	if ($_FILES['file']['name'] != "")
	{
		if ((($_FILES["file"]["type"] == "image/gif")
		|| ($_FILES["file"]["type"] == "image/jpeg")
		|| ($_FILES["file"]["type"] == "image/png")
		|| ($_FILES["file"]["type"] == "image/pjpeg"))
		&& ($_FILES["file"]["size"] < 1050000))
		{
		$name = str_replace(" ", "_", $_FILES['file']['name']);
		$random_digit=rand(0000,9999);
		$random_name = $random_digit.$name;
		$random_name_thumb = "t_".$random_digit.$name;
		
		$path = "../fotos/".$random_name;
		$path_thumb = "../fotos/".$random_name_thumb;
		
		$img_link= "fotos/".$random_name;
		$img_link_thumb= "fotos/".$random_name_thumb;
		
		move_uploaded_file($_FILES["file"]["tmp_name"], $path);
		copy($path, $path_thumb);
		
		$yuklandi = " Asosiy rasm yuklandi, ";
		
/************************ 
 ** Image resize block **
************************/
//include class file
			$obj = new img_opt();
			// set maximum width within wich the image should be resized
			$obj->max_width(160);
			// set maximum height within wich the image should be resized
			// for example size of the area in which image to be displayed
			$obj->max_height(160);
			$obj->image_path($path_thumb);
			// call the functio to resize the image
			$obj->image_resize();
			
			$obj = new img_opt();
			// set maximum width within wich the image should be resized
			$obj->max_width(500);
			// set maximum height within wich the image should be resized
			// for example size of the area in which image to be displayed
			$obj->max_height(400);
			$obj->image_path($path);
			// call the functio to resize the image
			$obj->image_resize();
			/* End of Block */
		}
		else
		{
		$yuklanmadi = "<p class='error'>Xatolik, rasm olinmadi, <br>Chunki rasm faqat jpg, bmp, png, gif turdagi bo'lishi shart va <br> Rasm hajmi 1MB gacha bo'lishi lozim, <br>iltimos rasmingiz hajmini yoki fayl turini tekshiring</p>";
		}
	}
	else 
	{ $yuborilmadi =  "<p class='error'> Asosiy Rasm Yuborilmadi </p>";}
	
/* 2-rasm start */
	if ($_FILES['file2']['name'] != "")
	{
		if ((($_FILES["file2"]["type"] == "image/gif")
		|| ($_FILES["file2"]["type"] == "image/jpeg")
		|| ($_FILES["file2"]["type"] == "image/png")
		|| ($_FILES["file2"]["type"] == "image/pjpeg"))
		&& ($_FILES["file2"]["size"] < 1050000))
		{
		$name = str_replace(" ", "_", $_FILES['file2']['name']);
		$random_digit=rand(0000,9999);
		$random_name = $random_digit.$name;
		
		$path = "../fotos/".$random_name;
		$img_link2= "fotos/".$random_name;
		
		move_uploaded_file($_FILES["file2"]["tmp_name"], $path);
			
		$yuklandi2 = " 2- Rasm yuklandi, ";
/************************ 
 ** Image resize block **
************************/
//include class file
			$obj = new img_opt();
			// set maximum width within wich the image should be resized
			$obj->max_width(500);
			// set maximum height within wich the image should be resized
			// for example size of the area in which image to be displayed
			$obj->max_height(400);
			$obj->image_path($path);
			// call the functio to resize the image
			$obj->image_resize();
			/* End of Block */
		}
		else
		{
		$yuklanmadi = "<p class='error'> Xatolik, rasm olinmadi, <br>Chunki rasm faqat jpg, bmp, png, gif turdagi bo'lishi shart va <br> Rasm hajmi 1MB gacha bo'lishi lozim, <br>iltimos rasmingiz hajmini yoki fayl turini tekshiring </p>";
		}
	}
	else 
	{ $yuborilmadi2 =  "<p class='error'>2-rasmni yubormadingiz</p>";}
/* 2-rasm finish */

/* 3-rasm start */
	if ($_FILES['file3']['name'] != "")
	{
		if ((($_FILES["file3"]["type"] == "image/gif")
		|| ($_FILES["file3"]["type"] == "image/jpeg")
		|| ($_FILES["file3"]["type"] == "image/png")
		|| ($_FILES["file3"]["type"] == "image/pjpeg"))
		&& ($_FILES["file3"]["size"] < 1050000))
		{
		$name = str_replace(" ", "_", $_FILES['file3']['name']);
		$random_digit=rand(0000,9999);
		$random_name = $random_digit.$name;
		
		$path = "../fotos/".$random_name;
		$img_link3= "fotos/".$random_name;
		
		move_uploaded_file($_FILES["file3"]["tmp_name"], $path);
			
		$yuklandi3 = "3 - Rasm yuklandi, ";
/************************ 
 ** Image resize block **
************************/
//include class file
			$obj = new img_opt();
			// set maximum width within wich the image should be resized
			$obj->max_width(500);
			// set maximum height within wich the image should be resized
			// for example size of the area in which image to be displayed
			$obj->max_height(400);
			$obj->image_path($path);
			// call the functio to resize the image
			$obj->image_resize();
			/* End of Block */
		}
		else
		{
		$yuklanmadi = "<p class='error'>Xatolik, rasm olinmadi, <br>Chunki rasm faqat jpg, bmp, png, gif turdagi bo'lishi shart va <br> Rasm hajmi 1MB gacha bo'lishi lozim, <br>iltimos rasmingiz hajmini yoki fayl turini tekshiring</p>";
		}
	}
	else 
	{ $yuborilmadi3 =  "<p class='error'> 3-rasmni yubormadingiz</p>";}
/* 3-rasm finish */
?>